package com.weic.flink.dataset.source

import org.apache.flink.api.scala._

/**
 * @Auther:BigData-weic
 * @ClassName:Demo01FlinkWordCount
 * @Date:2020/12/16 20:41
 * @功能描述: $FunctionDescription
 * @Version:1.0
 */
object Demo01FlinkWordCount {
	def main(args: Array[String]): Unit = {
		val env = ExecutionEnvironment.getExecutionEnvironment
		val lines = env.fromElements(
			"where there is a will",
			"there is a way",
			"one day one apple",
			"doctor far away me"
		)
		val ret = lines.flatMap(_.split("\\s+"))
			.map((_, 1))
			.groupBy(0)
			.sum(1)
		ret.print()
	}

}
